// const imageUrl = "/image"

const imageUrl = "https://cyxf.xfyh4k5.com/jiazheng/image"
const newimageUrl = "https://appimgs.xfyh4k5.com/Housekeeping/"
const happyimageUrl = "https://cyxf.xfyh4k5.com/happyhome/image"

const savePhoto = (imgSrc) => {
  // 保存base64图片 需先 imgSrc.slice(22)
  let img_Src = imgSrc.slice(22)
  var save = wx.getFileSystemManager();
  var number = Math.random();
  save.writeFile({
    filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.png',
    data: img_Src,
    encoding: 'base64',
    success: res => {
      wx.saveImageToPhotosAlbum({
        filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.png',
        success: function (res) {
          wx.showToast({
            title: '保存成功',
          })
        },
        fail: function (err) {
          console.log(err)
        }
      })
    },
    fail: err => {
      console.log(err)
    }
  })
}

module.exports = {
  imageUrl,
  newimageUrl,
  savePhoto,
  happyimageUrl
}